﻿using UnityEngine;
using System.Collections;

public class ProtectTarget : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    void OnTriggerEnter2D(Collider2D CollObj)
    {
        if (CollObj.gameObject.tag == "Enemy")
        {
            GameObject.Find("SceneDataMgr").GetComponent<SceneDataMgr>().m_iScore -= 1;
            GameSystem.GetInstance().DeleteThisUnit(CollObj.GetComponent<UnitStatus>(), false);
            

            if (GameObject.Find("SceneDataMgr").GetComponent<SceneDataMgr>().m_iScore < 0)
            {
                GameObject.Find("Middle").transform.GetChild(6).gameObject.SetActive(true);
            }
        }
    }

}
